<template>

  <div>
  <h1>车载终端系统</h1>
    <el-form :inline="true" :model="form1" label-width="80px">
      <el-form-item label="连接路径" >
        <el-input v-model="form1.url" ></el-input>
      </el-form-item>
      <el-button type="success" @click="open">连接</el-button>
      <el-button type="danger" @click="close">断开</el-button>
      <el-button type="primary" @click="sendCurrentLocaltion">开始上报报文</el-button>
      <el-button type="warning">停止上报报文</el-button>
    </el-form>

    <el-form :model="form2" label-width="80px" style="width: 500px">
      <el-form-item label="车辆VIN" >
        <el-input v-model="form2.vin"></el-input>
      </el-form-item>
      <el-form-item label="模拟路径">
        <el-select v-model="form2.id" placeholder="请选择">
          <el-option
            v-for="item in fimList"
            :key="item.id"
            :label="item.name"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
<!--      <el-row>-->
<!--        <el-button type="info" @click="sendBaseFault()">模拟基础故障</el-button>-->
<!--        <el-button type="warning" @click="sendPartsFault">模拟车辆零配件故障组</el-button>-->
<!--        <el-button type="danger" @click="sendBatteryFault">模拟车辆电池故障组</el-button>-->
<!--      </el-row>-->
    </el-form>
  </div>
</template>

<script>
import {
  openVehicle,
  closeVehicle,
  sendBaseFault,
  sendBatteryFault,
  sendPartsFault,
  sendCurrentLocaltion,
  findByIm
}
  from '@/api/vehicle/vehicleTerminal'
// import {findByPage} from "@/api/vehicle/manage";

export default {
  data() {
    return {
      form1:{
        url:'ws://localhost:9898/ws'
      },
      form2:{
        vin:''
      },
      fimList:[]
    }
  },
  methods: {
    open(){
      openVehicle(this.form1).then(res=>{
          this.$message.success("连接成功");
      })
    },
    close(){
      closeVehicle().then(res=>{
        this.$message.error("连接断开")
      })
    },
    // sendBaseFault(){
    //   sendBaseFault(this.form2.vin).then(res=>{
    //       this.$message.success("调用故障组成功")
    //   })
    // },
    // sendPartsFault(){
    //   sendPartsFault(this.form2.vin).then(res=>{
    //     this.$message.success("调用故障组成功")
    //   })
    // },
    // sendBatteryFault(){
    //   sendBatteryFault(this.form2.vin).then(res=>{
    //     this.$message.success("调用故障组成功")
    //   })
    // },
    sendCurrentLocaltion(){
      sendCurrentLocaltion(this.form2.vin).then(res=>{
      })
    }
  },
  created() {
    findByIm().then((response) => {
      //alert(response.rows)
      this.fimList = response.rows;
    });
  }
}
</script>

<style>

</style>
